﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DocManager.ViewModels.Schemas;
using Platform.ObjectModel;
using Platform.ObjectModel.Design;

namespace DocManager.Controllers
{
    public class SchemasController : Controller
    {
        //
        // GET: /Schema/

		public SchemasController()
			: this( new Library( new Platform.Storage.Entity.EntityLibraryStorage() ) )
		{ }

		public SchemasController( Library library )
		{
			this.Library = library;
		}

		public Library Library
		{ get; private set; }

        public ActionResult Index()
        {
			return this.List( Schema.SchemaNamespace.FullName );
			//return this.View( Schema.SchkczemaNamespace.FullName );
			//return View();
        }


		public ActionResult List( string qualifiedName )
		{
			// TODO : Selecionar o schema identificado por "qualifiedName"
			//var schema = new SchemaViewModel( this.Library.Workspace.GetSchema( qualifiedName ) );
			var schema = new SchemaViewModel( new Schema( DataObjectName.Parse( qualifiedName ) ) );

			return this.View( "DynamicDocList", schema );
		}
    }
}
